package com.cw.jeeyt.service.converter.system;
import java.util.List;
import java.util.ArrayList;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.system.SysScaffoldModuleFileBo;
import com.cw.jeeyt.dao.model.system.SysScaffoldModuleFileDo;
import com.cw.lang.common.utils.CollectionUtil;
/**
 * 脚手架模块文件转换类
 *
 * @author chenw
 * @date 2020-05-26 15:00:07
 */
public class SysScaffoldModuleFileConverter{

    /**
     * do转bo
     * @param model
     * @return
     */
    public static SysScaffoldModuleFileBo do2Bo(SysScaffoldModuleFileDo model) {
		SysScaffoldModuleFileBo bo = new SysScaffoldModuleFileBo();
        if (model == null) {
            return bo;
        }
                bo.setId(model.getId());
                bo.setModuleId(model.getModuleId());
                bo.setFileCode(model.getFileCode());
                bo.setFileName(model.getFileName());
                bo.setFilePath(model.getFilePath());
                bo.setFileType(model.getFileType());
                bo.setFileContent(model.getFileContent());
                bo.setFileComment(model.getFileComment());
                return bo;
    }

    /**
     * bo转do
     * @param bo
     * @return
     */
    public static SysScaffoldModuleFileDo bo2Do(SysScaffoldModuleFileBo bo) {
		SysScaffoldModuleFileDo model = new SysScaffoldModuleFileDo();
        if (bo == null) {
            return model;
        }
                model.setId(bo.getId());
                model.setModuleId(bo.getModuleId());
                model.setFileCode(bo.getFileCode());
                model.setFileName(bo.getFileName());
                model.setFilePath(bo.getFilePath());
                model.setFileType(bo.getFileType());
                model.setFileContent(bo.getFileContent());
                model.setFileComment(bo.getFileComment());
                return model;
    }

    /**
     * doList转boList
     * @param doList
     * @return
     */
    public static List<SysScaffoldModuleFileBo> doList2BoList(List<SysScaffoldModuleFileDo> doList) {
        if(CollectionUtil.isEmpty(doList)){
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SysScaffoldModuleFileConverter::do2Bo));
    }

    /**
     * boList转doList
     * @param boList
     * @return
     */
    public static List<SysScaffoldModuleFileDo> boList2DoList(List<SysScaffoldModuleFileBo> boList) {
        if(CollectionUtil.isEmpty(boList)){
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SysScaffoldModuleFileConverter::bo2Do));
    }
}